{extend name="public:base" /}
{block name="css"}

{/block}
{block name="content"}

<div class="account-info">
    <div class="screening">
        <form class="layui-form" action="" method="get">

            <div class="layui-form-item" style="clear: none;float: left">
                <label class="layui-form-label">用户ID</label>
                <div class="layui-input-inline">
                    <input type="text" name="user_id"  autocomplete="off" class="layui-input" value="{$Arr['user_id']? $Arr['user_id'] : ''}">
                </div>
            </div>
            <div class="layui-form-item" style="clear: none;float: left">
                <label class="layui-form-label">收益类型</label>
                <div class="layui-input-inline">
                    <select name="type">
                        <option value="1"  {$Arr['type'] == 1 ? 'selected' : ''}>消费提成</option>
                        <option value="2"  {$Arr['type'] == 2 ? 'selected' : ''}>绩效奖</option>
                        <option value="3"  {$Arr['type'] == 3 ? 'selected' : ''}>管理奖</option>
                        <option value="4"  {$Arr['type'] == 4 ? 'selected' : ''}>平级奖</option>
                        <option value="5"  {$Arr['type'] == 5 ? 'selected' : ''}>推荐奖</option>
                    </select>
                </div>
            </div>
            <div class="layui-form-item" style="clear: none;float: left">
                <label class="layui-form-label">开始时间</label>
                <div class="layui-input-inline">
                    <input type="text" class="layui-input" lay-verify="start_time" value="{$Arr['start_time']? $Arr['start_time'] : ''}" name="start_time" id="start_time" placeholder="yyyy-MM-dd HH:mm:ss">
                </div>
            </div>
            <div class="layui-form-item" style="clear: none;float: left">
                <label class="layui-form-label">结束时间</label>
                <div class="layui-input-inline">
                    <input type="text" class="layui-input" name="end_time" value="{$Arr['end_time']? $Arr['end_time'] : ''}" id="end_time" placeholder="yyyy-MM-dd HH:mm:ss">
                </div>
            </div>

            <div class="layui-form-item" style="clear: none;float: left">
                <div class="layui-input-block">
                    <button class="layui-btn" lay-submit lay-filter="formDemo">确定</button>
                </div>
            </div>
            <div style="clear: both"></div>
        </form>
    </div>
    <div class="info">
        <table id="demo" class="layui-table" lay-data="{height:730, url:'{$url}', page:true, id:'test'}" lay-filter="test">
            <thead>
            <tr>
                <th lay-data="{field:'id', width:60, sort: true}">ID</th>
                <th lay-data="{field:'user_id', width:100, sort: true}">用户ID</th>
                <th lay-data="{field:'nickname', width:100}">用户账号</th>
                <th lay-data="{field:'levelName', width:100}">等级</th>
                <th lay-data="{field:'money', width:150}">收益总额</th>
                <th lay-data="{field:'other', width:150}">来源用户ID</th>
                <!--<th lay-data="{field:'integral', width:150}">积分</th>
                <th lay-data="{field:'outlay', width:150}">维护费</th> -->
                <th lay-data="{field:'typeName', width:150}">收益类型</th>
                <th lay-data="{field:'c_time', width:200, sort: true}">收益时间</th>
            </tr>
            </thead>
        </table>
    </div>
</div>


{/block}

{block name="javascript"}

<script type="text/javascript">

    layui.use('table', function(){
        var table = layui.table;
        //监听工具条
        table.on('tool(test)', function(obj){ //注：tool是工具条事件名，test是table原始容器的属性 lay-filter="对应的值"
            var data = obj.data; //获得当前行数据
            var layEvent = obj.event; //获得 lay-event 对应的值
            var tr = obj.tr; //获得当前行 tr 的DOM对象

            if(layEvent === 'detail'){ //查看
                var id = data.id;
                layui.use('layer', function(){
                    var layer = layui.layer;
                    layer.open({
                        title:"订单详情",
                        type: 2,
                        area: ['800px', '800px'],
                        content: ['/admin/Package/order_details?id='+id, 'no'],
                        end: function () {
                            location.reload();
                        }
                    });
                });
            }else if(layEvent === 'del'){ //失败
                var status = data.statusVal;
                if( status == 10 || status == 15 ){
                    prompt_From_one("此订单不能删除");
                    return false;
                }
                layer.confirm('确定为删除吗？不可更改！', function(index){

                    var id = data.id;
                    $.ajax({
                        type: 'POST',
                        url: '{:url("Package/order_del")}',
                        dataType: 'json',
                        data: {id: id,status:0},
                        success: function (data) {
                            layer.close(index);
                            if( data.result != 0 ){
                                prompt_From_one(data.msg);
                            }else{
                                location.reload();
                            }
                        }
                    });
                    //向服务端发送删除指令
                });

            }
        });


    });

    layui.use('form', function(){
        var form = layui.form;
        form.verify({
            start_time: function(value){
                var  end_time = $("#end_time").val();
                if( end_time != ""){
                    if( value == "" ){
                        return '请选择开始时间';
                    }
                }
            }
        });
    });

    layui.use('laydate', function(){
        var laydate = layui.laydate;
        //时间选择器
        laydate.render({
            elem: '#start_time'
            ,type: 'datetime'
            ,trigger: 'click'
        });
        laydate.render({
            elem: '#end_time'
            ,type: 'datetime'
            ,trigger: 'click'
        });
    });

</script>
{/block}